package com.xinda.admin.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.xinda.admin.dao.TypeMapper;
import com.xinda.admin.pojo.ProductStyle;
import com.xinda.admin.pojo.ProductType;

@Component(value="typeService")
public class TypeServiceImpl implements ITypeService {
	
	@Autowired
	private TypeMapper typeMapper;

	public List<ProductType> queryTypeList(int styleId) {
		
		ProductStyle style = new ProductStyle();
		if(styleId != 0){
			style.setId(styleId);
		}

		return typeMapper.selectTypeList(style);
	}

	public List<ProductStyle> queryStyleList() {
		return typeMapper.selectStyleList();
	}

	public ProductType queryTypeById(int id) {
		ProductType type = new ProductType();
		type.setId(id);
		return typeMapper.selectType(type);
	}

	public void deleteTypeById(int id) {
		typeMapper.deleteTypeById(id);
	}

	public void updateStatusById(int id, int status) {
		ProductType type = new ProductType();
		type.setId(id);
		type.setStatus(status);
		
		typeMapper.updateType(type);
	}

	public void updateTypeById(ProductType type) {
		typeMapper.updateType(type);
	}

	public void addTypeById(ProductType type) {
		typeMapper.insertType(type);
	}

}
